/*
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
			val(x), left(NULL), right(NULL) {
	}
};*/
class Solution {
public:
    // 如果路径的起点不是根节点呢？
    using vi = std::vector<int>;
    using  vvi = vector<vector<int>>;
    vector<vector<int>> FindPath(TreeNode* root,int expectNumber) {
        vi path;
        vvi ans;
        dfs(root, expectNumber, path, ans);
        return ans;
    }
    void dfs(TreeNode* cur, int tar, vi& path, vvi& ans) {
        if(!cur) return ;
        path.push_back(cur->val);
        if(cur->val == tar && !cur->left && !cur->right) {
            ans.push_back(path);
        }
        dfs(cur->left, tar-cur->val, path, ans);
        dfs(cur->right, tar-cur->val, path, ans);
        path.pop_back();
    }
};